AOP stands for Aspect Oriented Programming, allow you insert extra logics
Ways to declare point cut
Case #1, declare point cut outside target package
1 | "@annotation(com.xxx.SomeAnnotation)") ( |
Case #2, declare point cut inside target package
1 | // namespace of SomeAnnotation was removed |
Case #3, declare point cut by advice directly
1 | "@annotation(com.xxx.SomeAnnotation)") ( |
Advices types
@Before & @After, do something before or after the method execution
1 | "PointCutMethod()") ( |
@Around, execute method by calling prceed() of ProceedingJoinPoint. So you can do things around the execution.
1 | "PointCutMethod()") ( |
@AfterReturning, can get the retrun value after the method execution
1 | "PointCutMethod()", returning = "retVal") (PointCut = |
@AfterThrowing, can get the exeception if the method throws
1 | "PointCutMethod()", throwing = "error") (PointCut = |
PointCut Expression
PointCut declare where the advices should work on